// 这个模块主要是SPU得数据得模块
import request from '@/utils/request'

// 获取spu列表
export const reqSpuList = (page, limit, category3Id) => request({
  url: `/admin/product/${page}/${limit}`,
  params: {
    category3Id
  }
})

// 获取spu信息
export const reqSpu = (spuId) => request({
  url: `/admin/product/getSpuById/${spuId}`
})

// 获取品牌信息
export const reqTradeMarkList = () => request({
  url: '/admin/product/baseTrademark/getTrademarkList'
})

// 获取spu图片的接口
export const reqSpuImage = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`
})

// 获取平台全部销售属性 一共三个
export const reqBaseSaleAttrList = () => request({
  url: '/admin/product/baseSaleAttrList'
})

// 修改spu || 添加spu
export const reqAddOrUpdateSpu = (spuInfo) => {
  // 携带的参数带有id ---> 修改spu
  if (spuInfo.id) {
    return request({
      url: '/admin/product/updateSpuInfo',
      method: 'post',
      data: spuInfo
    })
  } else {
    return request({
      url: '/admin/product/saveSpuInfo',
      method: 'post',
      data: spuInfo
    })
  }
}

// 删除SPU
export const reqDeleteSpu = (spuId) => request({
  url: `/admin/product/deleteSpu/${spuId}`,
  method: 'delete'
})

// 获取图片接口
export const reqSpuImageList = (spuId) => request({
  url: `/admin/product/spuImageList/${spuId}`
})

// 获取销售属性列表
export const reqSpuSaleAttrList = (spuId) => request({
  url: `/admin/product/spuSaleAttrList/${spuId}`
})

// 获取平台属性信息
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => request({
  url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
})

// 添加sku
export const reqAddSku = (skuInfo) => request({
  url: '/admin/product/saveSkuInfo',
  method: 'post',
  data: skuInfo
})

// 获取sku数据列表的接口
export const reqSkuList = (spuId) => request({
  url: `/admin/product/findBySpuId/${spuId}`
})
